<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ page import="javax.servlet.http.*" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户登录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style>
		.red {
			color:#f00;
			font-size:12px;
		}
	</style>
  </head>
  
  <body>
  
  	<%
  		String loginId = "";
  	    String loginPwd = "";
  	    
  	    Cookie[] userCookies = request.getCookies();
  	    if(userCookies != null){
  	    	for(Cookie cookie : userCookies){
  	    		if(cookie.getName().equalsIgnoreCase("userCookieKey")){
  	    			String userInfo  = cookie.getValue();
  	    			String[] values = userInfo.split("_");
  	    			loginId = values[0];
  	    			loginPwd = values[1];
  	    		}
  	    	}
  	    }
  	%>
    <form method="post" action="loginHandle.jsp">
    	<table border="0" align="center">
			<tr>
				<td>用户名：</td>
				<td><input type="text" name="loginId" value="<%= loginId %>"></td>
			</tr>
			<tr>
				<td>密码</td>
				<td><input type="password" name="loginPwd" value="<%= loginPwd %>"></td>
			</tr>
			<tr>
				<td colspan="2" class="red">${ ErrorMsg }</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="checkbox" name="rememberMe" id="rememberMe" value="true" />
					<label for="rememberMe">记住我一周</label>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input type="submit" value="登陆"/>
					<input type="reset" value="重置 "/>
				</td>
			</tr>
		</table>
    </form>
  </body>
</html>
